home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE23 / SURVIVE / fmIssue.pas < prev    next >
Pascal/Delphi Source File  |  1997-05-19  |  2KB  |  77 lines

  1. unit Fmissue;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, DB, DBTables;
  8.  
  9. type
  10.   TfrmIssue = class(TForm)
  11.     GroupBox1: TGroupBox;
  12.     Label1: TLabel;
  13.     edtNumber: TEdit;
  14.     Label2: TLabel;
  15.     edtAmount: TEdit;
  16.     btnPost: TButton;
  17.     btnCancel: TButton;
  18.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  19.     procedure btnPostClick(Sender: TObject);
  20.   private
  21.   public
  22.     CustomerNo: LongInt;
  23.     procedure PopulateForm;
  24.   end;
  25.  
  26. var
  27.   frmIssue: TfrmIssue;
  28.  
  29. function ShowCreditIssueDlg(aCustomerNo: LongInt): TModalResult;
  30.  
  31. implementation
  32.  
  33. {$R *.DFM}
  34.  
  35. uses
  36.   dmData;
  37.  
  38. function ShowCreditIssueDlg(aCustomerNo: LongInt): TModalResult;
  39. begin
  40.   Application.CreateForm(TfrmIssue, frmIssue);
  41.   try
  42.     with frmIssue do begin
  43.       CustomerNo := aCustomerNo;
  44.       PopulateForm;
  45.       Result := ShowModal;
  46.     end;
  47.   finally
  48.     frmIssue.Release;
  49.   end;
  50. end;
  51.  
  52. procedure TfrmIssue.PopulateForm;
  53. begin
  54.   with dmDataModule.spCreditNew do begin
  55.     ParamByName('iCreditNo').Clear;
  56.     ParamByName('iCustNo').AsInteger := CustomerNo;
  57.     ExecProc;
  58.     edtNumber.Text := IntToStr(ParamByName('oCreditNo').AsInteger);
  59.   end;
  60. end;
  61.  
  62. procedure TfrmIssue.FormClose(Sender: TObject; var Action: TCloseAction);
  63. begin
  64.   Action := caFree;
  65. end;
  66.  
  67. procedure TfrmIssue.btnPostClick(Sender: TObject);
  68. begin
  69.   with dmDataModule.qryCreditIssue do begin
  70.     ParamByName('CreditNo').AsInteger := StrToInt(edtNumber.Text);
  71.     ParamByName('Amount').AsFloat := StrToFloat(edtAmount.Text);
  72.     ExecSQL;
  73.   end;
  74. end;
  75.  
  76. end.
  77.